package com.global.college.api;


import com.global.college.ui.bean.InviteHistoryModel;
import com.global.college.ui.bean.InviteInfoModel;
import com.global.college.ui.bean.LoginModel;


import okhttp3.RequestBody;
import retrofit2.http.Body;

import com.global.college.ui.bean.UploadHeaderModel;
import com.global.college.ui.bean.UserDataModel;
import com.global.college.ui.bean.WechatLoginModel;

import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import rx.Observable;

/**
 * Created by fu on 2020/2/18.
 * Describe: 请求封装（服务端要求请求体同意使用json，故使用requestBody请求体）
 */
public interface AuthServerAPI {
    /**
     * 2. 获取微信token
     */
    @Streaming
    @GET(AuthURLs.WECHAT_TOKEN)
    Observable<HttpResult<BaseResponseModel>> getWechatToken(@Header("appid") String appid, @Header("secret") String secret, @Header("code") String code, @Header("grant_type") String grant_type);
    /**
     * 3.用户注册
     * phone         手机号
     * code          验证码
     * password      密码
     * invit_code      推荐码
     */
    @POST(AuthURLs.REGIST)
    Observable<HttpResult<BaseResponseModel>> regist(@Body RequestBody body);//uton_edu_android

    @GET(AuthURLs.GET_INVITE_INFO)
    Observable<HttpResult<InviteInfoModel>> getInviteInfo(@Header("Authorization") String auth);


    @GET(AuthURLs.GET_INVITE_RECORD_REGISTER)
    Observable<HttpResult<InviteHistoryModel>> getInviteRegisterList(@Header("Authorization") String auth,@Query("pageNum") int pageNum,@Query("pageSize") int pageSize);

    @GET(AuthURLs.GET_INVITE_RECORD_PAID)
    Observable<HttpResult<InviteHistoryModel>> getInvitePaidList(@Header("Authorization") String auth,@Query("pageNum") int pageNum,@Query("pageSize") int pageSize);

    /**
     * 4.登录
     * username	     用户名
     * password	    密码
     * code	        验证码
     * source	    来源
     */
    @POST(AuthURLs.LOGIN)
    Observable<HttpResult<LoginModel>> login(@Body RequestBody body);
    /**
     * 5.找回密码
     * code	        验证码
     * password	    密码
     * username	    用户名
     */

    @POST(AuthURLs.FIND_PSW)
    Observable<HttpResult<BaseResponseModel>> findPsw( @Body RequestBody body);
    /**
     * 6.退出登录
     */
    @POST(AuthURLs.LOGIN_OUT)
    Observable<HttpResult<BaseResponseModel>> loginOut(@Header("Authorization") String auth);
    /**
     * 7.获取验证码
     * phone	手机号
     */
    @POST(AuthURLs.GET_SMS_CODE)
    Observable<HttpResult<BaseResponseModel>> getSmsCode(@Body RequestBody body);

    /**
     * 10. 修改用户手机号
     * Authorization
     * code	        验证码
     * phone        电话
     * userName	    用户账号
     */
    @POST(AuthURLs.EDIT_PHONE)
    Observable<HttpResult<BaseResponseModel>> editPhone(@Header("Authorization") String auth, @Body RequestBody body);
    /**
     * 11.修改用户密码
     * Authorization
     * confirmPassword	    确认密码
     * newPassword	        新密码
     * oldPassword	        原密码
     * userName	            用户账号
     */
    @POST(AuthURLs.EDIT_PSW)
    Observable<HttpResult<BaseResponseModel>> editPsw(@Header("Authorization") String auth, @Body RequestBody body);
    /**
     * 12.获取用户信息
     * Authorization
     */
    @GET(AuthURLs.GET_USER_INFO)
    Observable<HttpResult<UserDataModel>> getUserInfo(@Header("Authorization") String auth);
    /**
     * 12.设置用户信息
     * Authorization
     * avatar	     用户头像
     * nickName	     用户昵称
     * sex	        用户性别 用户性别（0男 1女 2未知）
     * userName	    用户账号
     */

    @POST(AuthURLs.SET_USER_INFO)
    Observable<HttpResult<BaseResponseModel>> setUserInfo(@Header("Authorization") String auth, @Body RequestBody body);

    /**
     * 14. 上传头像
     * Authorization
     * fileName	文件类型
     */
    @POST(AuthURLs.UPLOAD_AVATAR)
    Observable<HttpResult<UploadHeaderModel>> uploadAvatar(@Header("Authorization") String auth, @Body RequestBody body);

    /**
     * 15. 微信移动端登录
     * openId
     * unionid
     * accessToken
     *
     *  code
     *  source
     *  userName
     */
    @POST(AuthURLs.WECHECT_LOGIN)
    Observable<HttpResult<WechatLoginModel>> wechatLogin(@Header("Authorization") String auth,@Body RequestBody body);
    @POST(AuthURLs.WECHECT_LOGIN)
    @FormUrlEncoded
    Observable<HttpResult<WechatLoginModel>> wechatLogin(@Header("Authorization") String auth, @Field("openId") String openId, @Field("unionid") String unionid, @Field("accessToken") String accessToken, @Field("code") String code, @Field("source") String source, @Field("userName") String userName);
}